﻿//  Write a program that finds all prime numbers in the range [1...10 000 000]. Use the sieve of Eratosthenes algorithm (find it in Wikipedia).


using System;

namespace Eratosthenes
{
    class Eratosthenes
    {
        static void Main()
        {
            int[] nums = new int[10000000];
            for (int i = 0; i < nums.Length; i++)
            {
                nums[i] = i + 1;
            }
            for (int index = 0; index < nums.Length; index++)
            {
                for (int check = 2; check <= nums[index]; check++)
                {
                    bool checking = nums[index] % check == 0;
                    if (checking == true && (check == nums[index]))
                    {
                        Console.WriteLine(nums[index]);
                    }
                    else if (checking == true && (check != nums[index]))
                    {
                        break;
                    }
                    else if (checking == false)
                    {
                        if (check <= nums[index])
                        {
                            continue;
                        }
                        else if (check == nums[index])
                        {
                            Console.WriteLine(nums[index]);
                        }
                    }
                }
            }
        }
    }
}
